package com.tac.controller.wms;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.wms.VehicleDispatch;
import com.tac.service.wms.VehicleDispatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vehicleDispatch")
@CrossOrigin
@Api(tags = "智能仓储WMS--运输管理--车辆调度")
public class VehicleDispatchController {

    @Autowired
    private VehicleDispatchService vehicleDispatchService;

    // 查询列表
    @GetMapping("/getList")
    @ApiOperation("车辆调度查询列表")
    public Result<PageInfo<VehicleDispatch>> getList(@RequestParam(defaultValue = "1") Integer pageNum,
                                                     @RequestParam(defaultValue = "10") Integer pageSize,
                                                     @RequestParam(required = false) String documentNumber,
                                                     @RequestParam(required = false) String shipmentNo) {
        return vehicleDispatchService.getList(pageNum, pageSize, documentNumber, shipmentNo);
    }

    // 添加
    @PostMapping("/save")
    @ApiOperation("车辆调度添加")
    public Result save(@RequestBody VehicleDispatch vehicleDispatch) {
        return vehicleDispatchService.insert(vehicleDispatch);
    }

    // 更新
    @PutMapping("/update")
    @ApiOperation("车辆调度更新")
    public Result update(@RequestBody VehicleDispatch vehicleDispatch) {
        return vehicleDispatchService.update(vehicleDispatch);
    }

    // 删除
    @DeleteMapping("/delete")
    @ApiOperation("车辆调度删除")
    public Result delete(@RequestBody List<Integer> ids) {
        return vehicleDispatchService.delete(ids);
    }
}
